package org.hot100_2;

public class leetcode35 {
    public int searchInsert(int[] nums, int target) {
        int left = 0;
        int right = nums.length-1;
        //左闭右闭
        while (left<=right){
            int mid =(left+right)>>>1;
            int midNum = nums[mid];
            if (midNum==target){
                return mid;
            }else if (midNum<target){
                left=mid+1;
            }else if (target<midNum){
                right=mid-1;
            }
        }
        return left;
    }
}
